package com.dangdang.serviceImpl;

import java.util.List;

import org.hibernate.Session;

import com.dangdang.domain.ReceiveAddress;
import com.dangdang.service.ReceiveAddressService;
import com.dangdang.util.HbnUtils;

public class ReceiveAddressServiceImpl implements ReceiveAddressService {

	/**
	 * 添加一个地址
	 */
	@Override
	public void addReceiveAddress(ReceiveAddress receiveAddress) {
		Session s = HbnUtils.getSession();
		try {
			s.beginTransaction();
			s.save(receiveAddress);
			s.getTransaction().commit();
		} catch (Exception e) {
			s.getTransaction().rollback();
		} finally {
			s.close();
		}
	}

	/**
	 * 删除一个地址
	 */
	@Override
	public void deleteReceiveAddress(ReceiveAddress receiveAddress) {
		Session s = HbnUtils.getSession();
		try {
			s.beginTransaction();
			s.delete(receiveAddress);
			s.getTransaction().commit();
		} catch (Exception e) {
			s.getTransaction().rollback();
		} finally {
			s.close();
		}

	}

	/**
	 * 查找所有的地址
	 */
	@Override
	public List<ReceiveAddress> findAllReceiveAddress() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * 根据用户ID查看指定的地址
	 */
	@Override
	public ReceiveAddress findReceiveAddressByUserId(Integer userId) {
		return null;
	}

	@Override
	public void updateReceiveAddress(ReceiveAddress receiveAddress) {
		// TODO Auto-generated method stub

	}

}
